Xbasic

usps_zipcode_lookup Function

Syntax

ZipCode as C = usps_zipcode_lookup(C addr1 ,C city ,C state [,C addr2 [,C urbanization [,C zip5 ]]])

Arguments

ZipCode

A 9 digit ZIP code

addr1

The street portion of an address.

city

The city portion of an address.

state

The state portion of an address.

addr2

Optional. Default = "". A second street address.

urbanization

Optional. Default = "". Urbanization denotes an area, sector, or development within a geographic area. In addition to being a descriptive word, it precedes the name of the area. The URB descriptor, commonly used in Puerto Rican urban areas, is an important part of the addressing format of Puerto Rico, as it describes the location of a given street.

zip5

Optional. Default = "". A 5 or 9 digit ZIP code. The function truncates 9 digit codes to 5 digits.

Description

Contacts the USPS web site and looks up the zip code for the specified address. Returns "" if the zip is not found. Returns the first zip code if multiple are available for the specified address.

Discussion

The USPS_ZipCode_Lookup() function contacts the USPS web site and looks up the ZIP code for the specified address. The function returns "" (NULL) if the ZIP code is not found. It returns the first ZIP code if multiple are available for the specified address. Note : Use of this function requires an active Internet connection. ZIP codes are used by the US Postal Service (USPS) for addressing mail in the United States.

Example

? usps_zipcode_lookup("70 blanchard road", "burlington", "ma") 
= "01803-5100" 

? usps_zipcode_lookup("91 Middlesex Turnpike", "burlington", "ma") 
= "01803-4922" 

? usps_zipcode_lookup("1600 Pennsylvania Avenue NW", "Washington", "DC") 
= "20500-0003"